TRIOT: Faster tensor manipulation in C++11

نویسندگان

  • Oliver Serang
  • Florian Heyl
چکیده

Context: Multidimensional arrays are used by many different algorithms. As such, indexing and broadcasting complex operations over multidimensional arrays are ubiquitous tasks and can be performance limiting. Inquiry: Simultaneously indexing two ormoremultidimensional arrays with different shapes (e.g., copying data from one tensor to another larger, zero padded tensor in anticipation of a convolution) is difficult to do efficiently: Hard-coded nested for loops in C, Fortran, and Go cannot be applied when the dimension of a tensor is unknown at compile time. Likewise, boost::multi_array cannot be used unless the dimensions of the array are known at compile time, and the style of implementation restricts the user from using the index tuple inside a vectorized operation (as would be required to compute an expected value of a multidimensional distribution). On the other hand, iteration methods that do not require the dimensionality or shape to be known at compile time (e.g., incrementing and applying carry operations to index tuples or remapping integer indices in the flat array), can be substantially slower than hard-coded nested for loops. Approach:Using a few tasks that broadcast operations over multidimensional arrays, several existingmethods are compared: hard-coded nested for loops in C and Go, vectorized operations in Fortran, boost::multi_array, numpy, tuple incrementing, and integer reindexing. Knowledge: A new approach to this problem, “template-recursive iteration over tensors” (TRIOT), is proposed. This new method, which is made possible by features of C++11, can be used when the dimensions of the tensors are unknown at compile time. Furthermore, the proposed method can access the index tuple inside the vectorized operations, permitting much more flexible operations. Grounding: Runtimes of all methods are compared, and demonstrate that the proposed TRIOT method is competitive with both hard-coded nested for loops in C and Go, as well as vectorized operations in Fortran, despite not knowing the dimensions at compile time. TRIOT outperforms boost::multi_array, numpy, tuple incrementing, and integer reindexing. Importance: Manipulation of multidimensional arrays is a common task in software, especially in highperformance numerical methods. This paper proposes a novel way to leverage template recursion to iterate over and apply operations to multidimensional arrays, and then demonstrates the superior performance and flexibility of operations that can be achieved using this new approach.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

DERIVATIONS OF TENSOR PRODUCT OF SIMPLE C*-ALGEBRAS

In this paper we study the properties of derivations of A B, where A and B are simple separable C*-algebras, and A B is the C*-completion of A B with respect to a C*-norm Yon A B and we will characterize the derivations of A B in terms of the derivations of A and B

متن کامل

Bessel multipliers on the tensor product of Hilbert $C^ast-$‎ modules‎

In this paper, we first show that the tensor product of a finite number of standard g-frames (resp. fusion frames, frames) is a standard g-frame (resp. fusion frame, frame) for the tensor product of Hilbert $C^ast-$ modules and vice versa, then we consider tensor products of g-Bessel multipliers, Bessel multipliers and Bessel fusion multipliers in Hilbert $C^ast-$modules. Moreover, we obtain so...

متن کامل

A Note on Tensor Product of Graphs

Let $G$ and $H$ be graphs. The tensor product $Gotimes H$ of $G$ and $H$ has vertex set $V(Gotimes H)=V(G)times V(H)$ and edge set $E(Gotimes H)={(a,b)(c,d)| acin E(G):: and:: bdin E(H)}$. In this paper, some results on this product are obtained by which it is possible to compute the Wiener and Hyper Wiener indices of $K_n otimes G$.

متن کامل

On the Exponent of Triple Tensor Product of p-Groups

The non-abelian tensor product of groups which has its origins in algebraic K-theory as well as inhomotopy theory, was introduced by Brown and Loday in 1987. Group theoretical aspects of non-abelian tensor products have been studied extensively. In particular, some studies focused on the relationship between the exponent of a group and exponent of its tensor square. On the other hand, com...

متن کامل

Residual norm steepest descent based iterative algorithms for Sylvester tensor equations

Consider the following consistent Sylvester tensor equation[mathscr{X}times_1 A +mathscr{X}times_2 B+mathscr{X}times_3 C=mathscr{D},]where the matrices $A,B, C$ and the tensor $mathscr{D}$ are given and $mathscr{X}$ is the unknown tensor. The current paper concerns with examining a simple and neat framework for accelerating the speed of convergence of the gradient-based iterative algorithm and ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Programming Journal

دوره 1  شماره 

صفحات  -

تاریخ انتشار 2017